home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C05 / Handle.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  574 b   |  32 lines

  1. //: C05:Handle.cpp {O}
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Handle implementation
  7. #include "Handle.h"
  8. #include "../require.h"
  9.  
  10. // Define Handle's implementation:
  11. struct Handle::Cheshire {
  12.   int i;
  13. };
  14.  
  15. void Handle::initialize() {
  16.   smile = new Cheshire();
  17.   require(smile != 0);
  18.   smile->i = 0;
  19. }
  20.  
  21. void Handle::cleanup() {
  22.   delete smile;
  23. }
  24.  
  25. int Handle::read() {
  26.   return smile->i;
  27. }
  28.  
  29. void Handle::change(int x) {
  30.   smile->i = x;
  31. } ///:~
  32.